import React, {Component} from 'react';
import {withRouter} from "react-router-dom";


class Header extends Component {

    goBack =() => {
        this.props.history.goBack()
    }

    goAhead = () => {
        this.props.history.goForward()
    }

    render() {
        return (
            <div>
                <div className="page-header">
                    <h2>React Router Demo</h2>
                    <button className="btn btn-primary btn-sm" onClick={this.goBack}>回退</button>
                    <button className="btn btn-outline-success btn-sm"
                            onClick={this.goAhead}>前进
                    </button>
                </div>
            </div>
        );
    }
}
// 一般组件没有路由对象，如果需要实现路由组件调整，需要withRouter包装来实现路由跳转
export default withRouter(Header);